package com.ruoyi.energy.service.impl;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.energy.domain.MjGuardAlarm;
import com.ruoyi.energy.mapper.MjGuardAlarmMapper;
import com.ruoyi.energy.service.IMjGuardAlarmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 门禁入侵警告Service业务层处理
 *
 * @author cjie
 * @date 2021-07-29
 */
@Service
public class MjGuardAlarmServiceImpl implements IMjGuardAlarmService {
    @Autowired
    private MjGuardAlarmMapper mjGuardAlarmMapper;

    /**
     * 查询门禁入侵警告
     *
     * @param id 门禁入侵警告ID
     * @return 门禁入侵警告
     */
    @Override
    public MjGuardAlarm selectMjGuardAlarmById(String id) {
        return mjGuardAlarmMapper.selectMjGuardAlarmById(id);
    }

    /**
     * 查询门禁入侵警告列表
     *
     * @param mjGuardAlarm 门禁入侵警告
     * @return 门禁入侵警告
     */
    @Override
    public List<MjGuardAlarm> selectMjGuardAlarmList(MjGuardAlarm mjGuardAlarm) {
        return mjGuardAlarmMapper.selectMjGuardAlarmList(mjGuardAlarm);
    }

    /**
     * 新增门禁入侵警告
     *
     * @param mjGuardAlarm 门禁入侵警告
     * @return 结果
     */
    @Override
    public int insertMjGuardAlarm(MjGuardAlarm mjGuardAlarm) {
        mjGuardAlarm.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        mjGuardAlarm.setCreateTime(DateUtils.getNowDate());
        mjGuardAlarm.setCreateBy(SecurityUtils.getUsername());
        return mjGuardAlarmMapper.insertMjGuardAlarm(mjGuardAlarm);
    }

    /**
     * 修改门禁入侵警告
     *
     * @param mjGuardAlarm 门禁入侵警告
     * @return 结果
     */
    @Override
    public int updateMjGuardAlarm(MjGuardAlarm mjGuardAlarm) {
        mjGuardAlarm.setUpdateTime(DateUtils.getNowDate());
        mjGuardAlarm.setUpdateBy(SecurityUtils.getUsername());
        return mjGuardAlarmMapper.updateMjGuardAlarm(mjGuardAlarm);
    }

    /**
     * 批量删除门禁入侵警告
     *
     * @param ids 需要删除的门禁入侵警告ID
     * @return 结果
     */
    @Override
    public int deleteMjGuardAlarmByIds(String[] ids) {
        return mjGuardAlarmMapper.deleteMjGuardAlarmByIds(ids);
    }

    /**
     * 删除门禁入侵警告信息
     *
     * @param id 门禁入侵警告ID
     * @return 结果
     */
    @Override
    public int deleteMjGuardAlarmById(String id) {
        return mjGuardAlarmMapper.deleteMjGuardAlarmById(id);
    }
}
